/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package funcion;

import com.aetrion.flickr.Flickr;
import com.aetrion.flickr.REST;
import com.aetrion.flickr.photos.SearchParameters;
import com.aetrion.flickr.photos.PhotoList;
import com.aetrion.flickr.photos.PhotosInterface;
import com.aetrion.flickr.photos.Photo;
import java.util.ArrayList;
import java.util.List;

public class FlickrImageFinder {


        public List getImages(String Lugar) throws Exception {
            List photos = new ArrayList();

            String key="38de4d9a4094708f39a24c6f6e498089";
            String svr="www.flickr.com";
            REST rest=new REST();
            rest.setHost(svr);

            Flickr flickr=new Flickr(key, rest);
            flickr.setSharedSecret("14bad0062b6cc64b");
            Flickr.debugStream=false;

            SearchParameters searchParams=new SearchParameters();
            searchParams.setSort(SearchParameters.INTERESTINGNESS_DESC);

            //String[] tags=new String[]{"Ecuador","Correa"};
            //searchParams.setTags(tags);

            searchParams.setText(Lugar);

            //Initialize PhotosInterface object
            PhotosInterface photosInterface=flickr.getPhotosInterface();
            //Execute search with entered tags
            PhotoList photoList=photosInterface.search(searchParams,30,1);
            
            StringBuffer strBuf=new StringBuffer();

            if(photoList!=null){
               for(int i=0;i<photoList.size();i++){
                  Photo photo=(Photo)photoList.get(i);
                  String foto;
                  foto = (String) photo.getThumbnailUrl();
                  photos.add(foto);
                  strBuf.append("<img border=\"0\" src=\""+photo.getThumbnailUrl()+"\">");
               }

               System.out.println(strBuf.toString());

            }
            return photos;
        }
}